package com.xpgk.mvc.statistic.loseWeightList;

import java.text.ParseException;
import java.util.List;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.xpgk.mvc.base.BaseController;
import com.xpgk.mvc.organization.Organization;
import com.xpgk.mvc.scallVisit.ScallVisitXLS;

public class LoseWeightListController extends BaseController {

	LoseWeightListService loseWeightListService;
	
	public void index(){
		setAttr("curOrgan", Organization.dao.findById(getCUserOrganIds()));
		render("loseWeightList.html");
	}
	
	/*
	 * 顾客数据查询
	 */
	public void customerDataQuery() throws ParseException{
		String organIdsEmployee = getPara("organIdsEmployee");
		String arrivedMinDate = getPara("arrivedMinDate");
		String arrivedMaxDate = getPara("arrivedMaxDate");
		String hybh = getPara("hybh");
		String customerName = getPara("cusname");
		String customerPhone = getPara("customerPhone");
     	List<Record> result = loseWeightListService.customerDataQuey(organIdsEmployee, arrivedMinDate, arrivedMaxDate,customerName);
		renderJson(result);
	}
	/*
	 * 顾客数据Excel导出
	 */
	public void excel() throws Exception{
		List<Record> result = loseWeightListService.customerDataQuey(getPara("organIdsEmployee"), getPara("arrivedMinDate"), getPara("arrivedMaxDate"),getPara("customerName"));
		Organization organ = Organization.dao.findById(getPara("organIdsEmployee"));//门店
		String search_organIdsEmployee =organ.getStr(Organization.column_name).equals("")?"":("店面名称："+organ.getStr(Organization.column_name)+"，");
		String search_arrivedMinDate = getPara("arrivedMinDate").equals("")?"":(("最早日期：")+getPara("arrivedMinDate")+"，");
		String search_arrivedMaxDate = getPara("arrivedMaxDate").equals("")?"":(("最晚日期：")+getPara("arrivedMaxDate")+"，");
		String search_customerName = getPara("customerName").equals("")?"":(("顾客姓名：")+getPara("customerName")+"，");
		String search = search_organIdsEmployee+search_arrivedMinDate+search_arrivedMaxDate+search_customerName;
		render(new LoseWeightListXLS(search,result,"顾客减重排名表"));
	}
}
